package org.example.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.example.bean.Discount;
import org.example.service.DiscountService;
import org.example.util.JsonResult;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:Liu
 * @Testname:DiscountController
 * @Date:2025/8/19 9:59
 */
@RestController
@Slf4j
@RequestMapping("/discount")
public class DiscountController {

    @Resource
    private DiscountService discountService;

    @PostMapping("/saveOrUpdate")
    JsonResult SaveOrUpdate(Discount discount, HttpServletRequest request) {
        return discountService.SaveOrUpdate(discount,request.getHeader("token"));
    }

    @GetMapping("/{bookId}")
    JsonResult findDiscountPriceByBookId(@PathVariable("bookId") String bookId) {
        return discountService.findDiscountPriceByBookId(bookId);
    }
}
